======================
LIBRAIN PLUGIN VERSION
======================

This is a standalone plugin version of the librain effects library. It's
primary purpose to allow interfacing with the library with minimum effort
from scripting environments such as Lua.

The plugin exposes the librain interfaces via datarefs. Please note, that
the plugin doesn't attempt to do much error checking or hand-holding. You
should still read the librain documentation to understand what all of the
fields in the datarefs mean.

-------------------
DATAREF DESCRIPTION
-------------------

1) The plugin provides up to 4 glass surfaces (librain_glass_t) for
   rendering. The datarefs for each glass surface are arranged as follows:

    librain/glass[0]/...
    ...
    librain/glass[3]/...

   The names of the datarefs under these paths corresponds to the various
   fields in a librain_glass_t. See librain.h in the plugin for a detailed
   description.

2) Each glass surface needs an OBJ to be loaded prior to initializing it.
   To load an OBJ, set its path in the corresponding "filename" dataref
   and set the "load" dataref to '1' to initiate the load. File paths can
   be absolute, or relative (relative paths are relative to the X-Plane
   root folder).

    librain/glass[0]/obj/filename = "C:\X-Plane\Aircraft\MyPlane\test.obj"
    librain/glass[0]/obj/load = 1

   When an OBJ load succeeds, the library sets the corresponding `loaded'
   dataref to 1:

    librain/glass[0]/obj/loaded = 1

   If the OBJ load fails for whatever reason, the `loaded' dataref remains
   set to `0' and an error message with the reason is printed into the
   sim's Log.txt. You can reload an object after making changes by simply
   setting .../obj/load to '1' again.

   To load an OBJ with a position offset (when in use in PlaneMaker), set
   the corresponding .../obj/pos_offset/{x, y, z} datarefs first and then
   load the OBJ.

3) Define z-depth masking objects. The library allows for up to 20 masking
   objects by default. The loading procedure is similar to the main glass
   surface object. Use the following datarefs:

    librain/z_depth_obj[*]/filename = "path/to/object.obj"
    librain/z_depth_obj[*]/pos_offset/x
    librain/z_depth_obj[*]/pos_offset/y
    librain/z_depth_obj[*]/pos_offset/z
    librain/z_depth_obj[*]/load = 1      <- initiates object load

   Here '*' represents a number from 0 to 19.

4) To control global aspects of the library, use the following datarefs:

    librain/num_glass_use = 0 ... 3	<- Defines how many librain/glass[*]
					   structures you want to use.
					   This field MUST NOT be written
					   after the library has been
					   initialized. To make changes,
					   de-initialize the library first.

    librain/initialize = 1		<- Causes the library to initialize
					   itself. Do this AFTER setting up
					   all of the librain/glass[*]
					   structures and loading all OBJs
					   you plan to use. Set to '0' to
					   de-initialize the library and
					   make changes to the number of
					   glass structures used.

    librain/init_success		<- Will be set to '1' when the
					   library init has succeeded.

    librain/debug_draw = 1		<- Enables debug drawing of the
					   z-depth masking objects. Use
					   this to figure out object
					   positioning during development.

    librain/wipers_visible = 1		<- Turns on debug drawing of the
					   wiper position on the glass
					   surface.

    librain/verbose = 1			<- Turns on more verbose logging
					   into Log.txt. Use this to show
					   helpful messages about operations
					   that have succeeded (e.g. loading
					   of an OBJ). Normally the plugin
					   is quiet unless something went
					   wrong.

5) If your aircraft has windshield wipers, use the following datarefs
   to update their positions:

    librain/glass[*]/wiper[*]/angle = <RADIANS>
    librain/glass[*]/wiper[*]/is_moving = 0 or 1

   To get proper animation, these must be updated every flight loop.

-------------------------
MINIMUM QUICK START HOWTO
-------------------------

1) Turn on verbose mode and debug drawing:

    librain/verbose = 1
    librain/debug_draw = 1
    librain/wipers_visible = 1

2) Load the windshield OBJ:

    librain/glass[0]/obj/filename = "test.obj"
    librain/glass[0]/obj/load = 1

2a) OPTIONAL: define one or more z-depth masking objects and load them:

    librain/z_depth_obj[0]/filename = "fuselage.obj"
    librain/z_depth_obj[0]/load = 1
    librain/z_depth_obj[1]/filename = "cabin_interior.obj"
    librain/z_depth_obj[1]/load = 1
    ...

3) Tell the library to initialize itself:

    librain/initialize = 1
